var SceneHeader = function(options) {
	this.ctx=options.ctx;
	let editor=options.editor;
	this.globe = options.editor.globe;
	let _this=this;
	
	//编辑场景信息
	$('#scene-edit-btn').click(function() {
		editor.sceneEditor.edit();
	});
	
	$('#scene-name-span').click(function() {
		editor.sceneLayer.open();
	});
	
	//在线地图
	$('#srcOnlineMapBtn').click(function() {
		editor.sceneOnlineMap.library();
	});
	
	$('#addModelSceneBtn').click(function() {
		editor.sceneModelLibrary.open();
	});
	$('#add3dtitleModelSceneBtn').click(function() {
		editor.scene3dtitle.openLibrary();
	});
	
	$('#addVModelSceneBtn').click(function() {
		editor.sceneVideoFusion.open();
	});
	
	//绘制点
	$('#addPointSceneBtn').click(function() {
		editor.scenePointLibrary.open();
	});
	
	//绘制线
	$('#addPolylineSceneBtn').click(function() {
		editor.scenePolylineLibrary.open();
	});
	
	//绘制立体墙
	$('#addWallSceneBtn').click(function() {
		editor.sceneWallLibrary.open();
	});
	
	
	$('#addRectangleSceneBtn').click(function() {
		
	});
	
	
	$('#addPolygonSceneBtn').click(function() {
		editor.globe.drawPolygon({
		})
	});
	
	$('#addRoadLabelSceneBtn').click(function() {
		editor.sceneRoadMark.draw();
	});
	
	$('#addCircleSceneBtn').click(function() {
    	var entity=new VFG.DrawCircle(globe.viewer,{
    	});
    	entity.addListener('success',function(e){
    		console.log(e);
    	});
	});
	
	
	$('#addSceneBtn').click(function() {
		_this.closeTool();
		Cesium.Camera.DEFAULT_VIEW_RECTANGLE = Cesium.Rectangle.fromDegrees(90, -20, 110, 90);//西南东北，默认显示中国
		editor.sceneEditor.editScene();
		editor.globe.flyToChina();
	});
	$('#mySceneBtn').click(function() {
		editor.sceneEditor.myScene();
	});
	
	$('#addSatelliteSceneBtn').click(function() {
		editor.sceneSatellite.openLibrary();
	});
	
	$('#addAntennaSceneBtn').click(function() {
		editor.sceneAntenna.openLibrary();
	});
	
	$('#addSensorSceneBtn').click(function() {
		editor.sceneSensor.openLibrary();
	});
	$('#sceneHomeBtn').click(function() {
		editor.sceneEditor.flyToHome();
	});
	
	$('#previewSceneBtn').click(function() {
		editor.scenePreview.openLayerTree();
	});
	
	$('#animationSceneBtn').click(function() {
		editor.sceneAnimation.open();
	});
	$('#add3dtitleSceneBtn').click(function() {
		editor.scene3dtitle.openLibrary();
	});
	
	//===================测量工具======================
	$('#addMeasureLengthBtn').click(function() {
		editor.globe.measureLength({
		});
	});
	
	$('#addMeasureAreaBtn').click(function() {
		editor.globe.measureArea({
		});
	});
	
	//三角测量
	$('#addMeasureTriangleBtn').click(function() {
		editor.globe.measureTriangle({
		});
	});
	//清除
	$('#cleanMeasureBtn').click(function() {
		editor.globe.measureLayerMap.forEach(function (value,key){
			value.destroy();
		});
	});
	
	this.view2D;
	//清除
	$('#addView2DBtn').click(function() {
		_this.view2D = editor.globe.view2D({
			domId:'mars2dContainer',
			param:{}
		});
	});
	
	//清除
	$('#deleteView2DBtn').click(function() {
		if(_this.view2D){
			_this.view2D.destroy();
		}
	});
	
	//===================测量工具======================
	//清除
	
	form.render();
	
	form.on('switch(sceneEditSwitch)', function(data){
		editor.sceneEditor.setState(this.checked);
	});
	
	this.editor=editor;
	return this;
}

SceneHeader.prototype.showTool=function(){
	$("#srcNav").css("display","");
	$("#sceneHomeLi").css("display","");
	$("#previewSceneLi").css("display","");
	$("#animationSceneLi").css("display","");
	$("#sceneSwitchLi").css("display","");
	
	
	$("#scene-name-span").html("当前场景-》【"+this.editor.scene.name+"】");
} 

SceneHeader.prototype.closeTool=function(){
	this.editor.scene=null;
	$("#srcNav").css("display","none");
	$("#sceneHomeLi").css("display","none");
	$("#previewSceneLi").css("display","none");
	$("#animationSceneLi").css("display","none");
	$("#sceneSwitchLi").css("display","none");
	$("#scene-name-span").html("");
	this.editor.sceneEditor.clear();
}